@import './variables';

@mixin clearfix {
  &:after {
    content: '';
    display: table;
    clear: both;
  }
}

/*@mixin scrollBar {
  &::-webkit-scrollbar-track-piece {
    background: #d3dce6;
  }
  &::-webkit-scrollbar {
    width: 6px;
  }
  &::-webkit-scrollbar-thumb {
    background: #99a9bf;
    border-radius: 20px;
  }
}*/

//
// @name: scrollbar
// @access: public
// @author: 731913218@qq.com
// @param[$size]: number
// @param[$color]: color value
//
@mixin scrollbar($size: $scrollBarSize, $color: $scrollBarColor) {
  overflow: auto;

  &::-webkit-scrollbar {
    width: $size+px;
    height: $size+px;
    background-color: transparent;
  }

  &:hover {
    &::-webkit-scrollbar {
      width: $size+px;
      height: $size+px;
    }

    &::-webkit-scrollbar-thumb {
      border-radius: $size/2+px;
      background-color: $color;
    }
  }
}

@mixin relative {
  position: relative;
  width: 100%;
  height: 100%;
}

@mixin pct($pct) {
  width: #{$pct};
  position: relative;
  margin: 0 auto;
}

@mixin no-wrap() {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

@mixin extend-click() {
  position: relative;

  &:before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
  }
}

@mixin triangle($width, $height, $color, $direction) {
  $width: $width/2;
  $color-border-style: $height solid $color;
  $transparent-border-style: $width solid transparent;
  height: 0;
  width: 0;

  @if $direction==up {
    border-bottom: $color-border-style;
    border-left: $transparent-border-style;
    border-right: $transparent-border-style;
  }

  @else if $direction==right {
    border-left: $color-border-style;
    border-top: $transparent-border-style;
    border-bottom: $transparent-border-style;
  }

  @else if $direction==down {
    border-top: $color-border-style;
    border-left: $transparent-border-style;
    border-right: $transparent-border-style;
  }

  @else if $direction==left {
    border-right: $color-border-style;
    border-top: $transparent-border-style;
    border-bottom: $transparent-border-style;
  }
}

//
// @name: userSelect
// @access: public
//
@mixin user-select {
  user-select: text;

  * {
    user-select: text;
  }
}

//
// @name: flex
// @access: public
// @param[$direction]: row or column
//
@mixin flex($direction: row) {
  display: flex;
  flex-direction: $direction;
}

@mixin flex-item {
  flex-shrink: 0;
}

@mixin sub-item($size: 1, $direction: row) {
  flex-grow: $size;

  @if $direction=='row' {
    width: 1%
  }

  @else {
    width: 100%;
    height: 1%;
  }
}

@mixin a-center {
  align-items: center;
}

@mixin j-center {
  justify-content: center;
}

@mixin center {
  align-items: center;
  justify-content: center;
  align-content: center;
}

@mixin a-end {
  align-items: flex-end;
}

@mixin j-end {
  justify-content: flex-end;
}

//
// @name: textEllipsis
// @access: public
//
@mixin text-ellipsis {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

//
// @name: textLineEllipsis
// @access: public
//
@mixin text-line-ellipsis($lineHeight: 1.12, $line: 2) {
  line-height: $lineHeight;
  white-space: normal;
  text-overflow: -o-ellipsis-lastline;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: $line;
  line-clamp: $line;
  -webkit-box-orient: vertical;
}